package cn.iocoder.yudao.module.peizhen.dal.mysql.withdraw;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.peizhen.controller.app.withdraw.vo.AppWithdrawPageReqVO;
import cn.iocoder.yudao.module.peizhen.dal.dataobject.staff.StaffDO;
import cn.iocoder.yudao.module.peizhen.dal.dataobject.withdraw.WithDrawAndStaffDO;
import cn.iocoder.yudao.module.peizhen.dal.dataobject.withdraw.WithdrawDO;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.peizhen.controller.admin.withdraw.vo.*;

/**
 * 员工提现 Mapper
 *
 * @author duanxinli
 */
@Mapper
public interface WithdrawMapper extends BaseMapperX<WithdrawDO> {

    default PageResult<WithDrawAndStaffDO> selectPage(WithdrawPageReqVO reqVO) {
        return selectJoinPage(reqVO, WithDrawAndStaffDO.class, new MPJLambdaWrapperX<WithdrawDO>() // 查询 List
                .selectAll(WithdrawDO.class) // 查询 system_users 表的 all 所有字段
                .selectAs(StaffDO::getPayAccount, WithDrawAndStaffDO::getPayAccount)
                .selectAs(StaffDO::getPayName, WithDrawAndStaffDO::getPayName)
                .eqIfPresent(WithdrawDO::getStaffId, reqVO.getStaffId())
                .eqIfPresent(WithdrawDO::getOrderNum, reqVO.getOrderNum())
                .eqIfPresent(WithdrawDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(WithdrawDO::getCreateTime,reqVO.getCreateTime() )
                .likeIfPresent(WithdrawDO::getStaffName, reqVO.getStaffName())
                .orderByDesc(WithdrawDO::getCreateTime)
                .leftJoin(StaffDO.class, StaffDO::getId, WithdrawDO::getStaffId));

    }

    default PageResult<WithDrawAndStaffDO> selectPage(AppWithdrawPageReqVO reqVO) {
        return selectJoinPage(reqVO, WithDrawAndStaffDO.class, new MPJLambdaWrapperX<WithdrawDO>() // 查询 List
                .selectAll(WithdrawDO.class) // 查询 system_users 表的 all 所有字段
                .selectAs(StaffDO::getPayAccount, WithDrawAndStaffDO::getPayAccount)
                .selectAs(StaffDO::getPayName, WithDrawAndStaffDO::getPayName)
                .eqIfPresent(WithdrawDO::getStaffId, reqVO.getStaffId())
                .eqIfPresent(WithdrawDO::getOrderNum, reqVO.getOrderNum())
                .eqIfPresent(WithdrawDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(WithdrawDO::getCreateTime,reqVO.getCreateTime() )
                .likeIfPresent(WithdrawDO::getStaffName, reqVO.getStaffName())
                .orderByDesc(WithdrawDO::getCreateTime)
                .leftJoin(StaffDO.class, StaffDO::getId, WithdrawDO::getStaffId));
    }

}